# Contributor: Dmitry Zakharchenko <dmitz@disroot.org>
# Maintainer: Dmitry Zakharchenko <dmitz@disroot.org>
pkgname=exercism
pkgver=3.2.0
pkgrel=2
pkgdesc="Command-line client for exercism.io"
url="https://github.com/exercism/cli"
arch="all"
license="MIT"
makedepends="go"
options="!check"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/exercism/cli/archive/v$pkgver.tar.gz"
builddir="$srcdir"/cli-$pkgver

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"
export GOFLAGS="$GOFLAGS -modcacherw"

prepare() {
	default_prepare

	go mod edit -replace=github.com/fsnotify/fsnotify=github.com/fsnotify/fsnotify@v1.5.1
	go get -d github.com/fsnotify/fsnotify@v1.5.1
}

build() {
	go build -o bin/exercism exercism/main.go
}

package() {
	install -Dm755 bin/exercism "$pkgdir"/usr/bin/exercism

	install -Dm644 shell/exercism_completion.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 shell/exercism.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 shell/exercism_completion.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
1d874652caf9845ab2f2e9da96083b29e903f4ba3de3c9dd16185a291d3cb5e224fe2264129fd47ed3eed2918f366b7d96e6aeaafb2db8a94cc7e39556756b46  exercism-3.2.0.tar.gz
"
